package com.zhouqinuan.spring.cloud.develop.framework.demo.kafka.message.listener;

import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.zhouqinuan.spring.cloud.develop.framework.demo.kafka.message.topic.KafkaTopic;
import com.zhouqinuan.spring.cloud.develop.framework.demo.kafka.model.UserInfo;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class UserKafkaListener {

	@KafkaListener(id = KafkaTopic.UserInfo.group, topics = { KafkaTopic.UserInfo.name }, concurrency = "3")
	public void listen(UserInfo userInfo) throws Exception {
		log.info("Received: {}", JSON.toJSONString(userInfo));
	}

    @KafkaListener(id = KafkaTopic.UserInfo.group + 1, topics = { KafkaTopic.UserInfo.name })
    public void listen2(UserInfo userInfo) throws Exception {
        log.info("Received2: {}", JSON.toJSONString(userInfo));
    }
}
